package com.imooc.hadoop.mapreduce.topN;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

/**
 * @program: hadoop
 * @description: TopNMapper
 * @author: zengchen
 * @create: 2021-03-30 15:13
 **/
public class TopNMapper extends Mapper<LongWritable, Text, LongWritable, NullWritable> {

    Logger logger = LoggerFactory.getLogger(TopNMapper.class);

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        logger.info("map value={}", value);
        context.write(new LongWritable(Long.parseLong(value.toString())), NullWritable.get());
    }
}
